package org.kms.Controllers;

import org.kms.dao.gradeDao;
import org.kms.pojo.Grade;
import org.kms.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/Grade")
@CrossOrigin(value = "*")
public class grade {
    @Autowired
    private gradeDao gradeDao;

    @RequestMapping("/gradeIndex")
    @ResponseBody
    public List<Grade> gradeGetall(Integer gIId) throws Exception{
        return gradeDao.getbyGarden(gIId);
    }

    @RequestMapping("/gradeIndex2")
    @ResponseBody
    public ResponseResult<List<Grade>> geta(Integer gIId)throws Exception{
        return new ResponseResult<>(gradeDao.getbyGarden(gIId));
    }

    @RequestMapping("/add")
    @ResponseBody
    public ResponseResult add(Grade grade)throws Exception{
        gradeDao.add(grade);
        return ResponseResult.createSuccessResult();
    }
}
